/**
 * 准备actions——用于响应组件中的动作
 */
import { Store } from "westore";
import { Login, LoginOptions } from "../../../models/login";

class LoginStore extends Store<Pick<Login,"motto" | "userInfo">> {
  options: LoginOptions | undefined;
  login:Login;
  constructor(options?: LoginOptions) {
    super();
    this.options = options;
    this.data = {
      motto: "",
      userInfo: {
        username:"",
        password:""
      }
    };

    this.login = new Login({
      onUserInfoLoaded: () => {
        this.data.motto = this.login.motto;
        this.data.userInfo = this.login.userInfo;

        this.update("loginPage");
      },
    });
  }
  HandleLogin(){
    this.login.HandleLogin();
  }
  getUserProfile() {
    this.login.getUserProfile();
  }

  handleinputInfo(e: { detail: { value: any; }; }) {
    this.login.handleinputInfo(e);
  }
}

const loginStore = new LoginStore();
export default loginStore;